package com.web.productservice.controller;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.web.productservice.entity.Product;
import org.springframework.http.ResponseEntity;

/**
 * 限流处理类
 */
public class MyBlockHandler {

    //自定义限流处理方法
    public static String helloBlockHandler(BlockException ex){
        ex.printStackTrace();
        return "这是hello的限流处理";
    }

    public static ResponseEntity<Product> findProductByIdBlockHandler(Integer id,
                                                                      BlockException ex){
        Product product = new Product();
        product.setId(-1);
        product.setName("限流处理的商品数据");
        return ResponseEntity.ok(product);
    }
}